<?	

	class PreserveVariableClass

	{				

		var $ERROR = "";

		var $PreserveTableName;

		var $session_id;

				

		function clear_error()

		{

			$this->ERROR = "";

		}

		function PreserveVariableClass($PreserveTableName,$adodbcon)

		{			

			$this->PreserveTableName=$PreserveTableName;

			$this->adodbcon=$adodbcon;	

			$this->session_id=session_id();													

		}				

		function PreserveVariableUpdate($PreserveLink)

		{	

					$SelectPreserve="SELECT * FROM $this->PreserveTableName WHERE preserve_session='$this->session_id'";

					$RsPreserve=$this->adodbcon->Execute($SelectPreserve);	

					$NumPreserve = $RsPreserve->NumRows();					

					if($NumPreserve==0)

					{

						$InsertPreserve=" INSERT INTO $this->PreserveTableName SET ".

										"	  preserve_variable=\"".$PreserveLink."\"".										

										"	, preserve_session='".$this->session_id."'".

										"	, preserve_date= CURRENT_DATE ";

						$RsPreserve=$this->adodbcon->Execute($InsertPreserve);		

						if($this->adodbcon->ErrorNo()) 			

							die("Error In Insert PreserveTable :".$InsertPreserve.$this->adodbcon->ErrorMsg());		

					}

					else

					{

						$UpdatePreserve="UPDATE $this->PreserveTableName SET ".

										"	  preserve_variable=\"".mysql_quote($PreserveLink)."\"".																				

										"	, preserve_date= CURRENT_DATE ".

										"	WHERE preserve_session= '".$this->session_id."' ";

						$RsPreserve=$this->adodbcon->Execute($UpdatePreserve);							

						if($this->adodbcon->ErrorNo()) 			

							die("Error In Update PreserveTable :".$UpdatePreserve.$this->adodbcon->ErrorMsg());							

					}						

		}

		function PreserveVariableSelect()

		{	

			$SelectPreserve="SELECT * FROM $this->PreserveTableName WHERE preserve_session='$this->session_id'";

			$RsPreserve=$this->adodbcon->Execute($SelectPreserve);	

			$RowPreserve=$RsPreserve->FetchRow();			

							

			$PreserveLinkArr=explode("&",$RowPreserve['preserve_variable']);

			foreach($PreserveLinkArr as $val)

			{

				if(!empty($val))

				{

					$PreserveLinkSubArr=explode("=",$val);

					$PreserveLinkKeyName=$PreserveLinkSubArr[0];

					$PreserveLinkSubArrDouble[$PreserveLinkKeyName]=$PreserveLinkSubArr[1];

				}	

			}										

			return $PreserveLinkSubArrDouble;						

		}

				

	}	

?>